package com.zhijiaoyun.dao;

import com.zhijiaoyun.dao.core.IBaseDao;
import com.zhijiaoyun.model.LearnHistory;
import com.zhijiaoyun.model.dto.LearnHistoryDto;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author shisfish
 * @date 2017/6/6
 */
public interface ILearnHistoryDao extends IBaseDao<LearnHistory> {

    /**
     * page by userId
     *
     * @param beginIndex
     * @param pagesize
     * @param userId
     * @return
     */
    List<LearnHistory> pageLearnHistoryByUserId(int beginIndex, int pagesize, Long userId);

    /**
     * list by courseId and userId
     *
     * @param courseId
     * @param userId
     * @return
     */
    List<LearnHistory> selectLearnHistoryByCourseIdUserId(@Param("courseId") Long courseId, @Param("userId") Long userId);

    /**
     * get by lessonId and userId
     *
     * @param lessonId
     * @param userId
     * @return
     */
    LearnHistory selectByLessonIdUserId(@Param("lessonId") Long lessonId, @Param("userId") Long userId);

    /**
     * count by params
     *
     * @param username
     * @param coursename
     * @param userId
     * @return
     */
    int countByParams(@Param("username") String username, @Param("coursename") String coursename, @Param("userId") Long userId);

    /**
     * page by params
     *
     * @param beginIndex
     * @param pageSize
     * @param username
     * @param coursename
     * @param userId
     * @return
     */
    List<LearnHistory> pageByParams(@Param("beginIndex") int beginIndex, @Param("pageSize") int pageSize,
                                    @Param("coursename") String username, @Param("coursename") String coursename, @Param("userId") Long userId);

    /**
     * list dto by userId and courseId
     *
     * @param userId
     * @param courseId
     * @return
     */
    List<LearnHistoryDto> selectLessonHistory(@Param("userId") Long userId, @Param("courseId") Long courseId);

    /**
     * 获取最后一个学习的课程
     *
     * @param courseId
     * @param userId
     * @return
     */
    LearnHistory selectLastLearnHistory(@Param("courseId") Long courseId, @Param("userId") Long userId);
}